<!-- 课程卡片 -->
<template>
  <div class="expertCard">
    <div class="cardBanner">
      <!-- <img class="cardImg" src="../assets/expert.png" alt="" srcset="" /> -->
      <img
        class="cardImg"
        :src="$getImageUrl(cardData.originImg)"
        alt=""
        srcset=""
      />

      <!-- <div class="cardTag">名师面对面</div> -->
    </div>
    <div class="cardInfo">
      <div class="cardTitle moreHidden">{{ cardData.name }}</div>
      <div class="cardOther">{{ cardData.title }}</div>
    </div>
    <div class="cardMasking" @click="toDetail(cardData)">
      <div class="cardMasking_title">{{ cardData.name }}</div>
      <div class="cardMasking_text">
        {{ cardData.introduction }}
      </div>
      <!-- <div class="cardMasking_title">TA的热门课程</div>
        <div class="cardMasking_course">
          <div
            class="cardMasking_course_item"
            v-for="(item, index) in courseList"
            :key="index"
          >
            <div class="courseName">&nbsp;{{ item.name }}</div>
            <div class="courseCount">
              <span>{{ item.count }}</span
              >人看过
            </div>
          </div>
        </div> -->
    </div>
  </div>
</template>

<script>
export default {
  name: "expertCard",
  props: {
    cardData: {
      type: Object,
      default: () => {
        return {
          thumbImg: require("../assets/footerBg.png"),
          name: "课程名称",
          speaker: "讲师名称",
          hits: 0,
        };
      },
    },
  },
  data() {
    return {
      courseList: [
        // { name: "2024新版教材详细解读1111111111111111", count: 3000 },
        // { name: "2024新版教材详细解读222222222222222", count: 3000 },
        // { name: "2024新版教材详细解读3333333333333333", count: 3000 },
      ],
    };
  },
  methods: {
    // 跳转详情
    toDetail(val) {
      let params = {
        objectId: val.objectId,
      };
      const url = this.$router.resolve({
        path: '/expert/detail',
        query: params
      }).href;
      window.open(url, '_blank');
    },
  },
};
</script>

<style scoped lang="scss">
.expertCard {
  position: relative;
  width: 100%;
  // height: 280px;
  border-radius: 8px;
  box-shadow: $box-shadow;
  background-color: #fff;
  padding-bottom: 20px;
  &:hover {
    box-shadow: $box-shadow-hover;
    // background: #227BE5CC;
  }

  .cardBanner {
    width: 100%;
    height: 224px;
    position: relative;
    .cardImg {
      width: 100%;
      height: 100%;
      border-radius: 8px 8px 0 0;
      // object-fit: cover;
    }
    .cardImg:hover {
      // filter: brightness(25%); /* 图片变暗 */
    }

    .cardTag {
      color: #fff;
      padding: 4px 6px;
      border-radius: 2px 0px 0px 0px;
      background: rgba(0, 0, 0, 0.5);
      position: absolute;
      top: 12px;
      right: 12px;
      font-size: 12px;
      font-weight: 600;
      line-height: 16.8px;
    }
  }
  .cardInfo {
    padding: 12px 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .cardTitle {
      font-size: 14px;
      font-weight: 600;
      color: $text-title-color;
    }
    .cardOther {
      font-size: 12px;
      font-weight: 400;
      color: $text-color;
    }
  }
  // 蒙版信息
  .cardMasking {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    color: transparent;
    
    padding: 20px;
     border-radius: 8px;
    z-index: 9;
    // display: none;
    // background: #000;
    // color: red;

    &_title {
      font-size: 20px;
      font-weight: 600;
      padding-bottom: 5px;
      border-bottom: 1px solid transparent;
    }
    &_text {
      box-sizing: border-box;
      width: 100%;
      max-height: 140px !important;
      line-height: 20px;
      padding: 20px 0;
      margin-bottom: 20px;
      font-size: 14px;
      // letter-spacing: 2px;
      @include ellipsis2(6);
    }

    // 课程信息
    &_course {
      width: 100%;
      height: 70px;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      font-size: 12px;
      margin-top: 20px;

      &_item {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px;

        .courseName {
          width: 60%;
          text-decoration: underline;
          @include ellipsis;
        }
        .courseCount {
          // color: gray;
          color: transparent;
        }
      }
    }
  }
  .cardMasking:hover {
    display: block;
    color: #fff;
    cursor: pointer;
    background: #227be5cc; 

    transition: background-color 0.3s ease;
  }

  .cardMasking:hover .cardMasking_title {
    // border-bottom: 1px solid #fff;
  }

  .cardMasking:hover .courseCount {
    // color: gray;
  }

  .cardMasking:hover ~ .cardInfo {
  color: transparent !important;
}

}

</style>
